package com.ahp.dao.impl;

import java.util.List;

import com.ahp.bean.User;
import com.ahp.dao.UserDao;

public class UserDaoImpl extends GenericDAOImpl<User, Integer> implements UserDao {
	
	public UserDaoImpl() {
		super(User.class);
	}
	
	public UserDaoImpl(Class<User> clazz) {
		super(clazz);
	}

	public User getUser(Integer id) {
		return (User)this.getHibernateTemplate().get(User.class, id);
	}
	
	public void saveUser(User user) {
		this.getHibernateTemplate().save(user);
	}

	public void updateUser(User user) {
		this.getHibernateTemplate().update(user);
	}
	
	@SuppressWarnings("unchecked")
	public List<User> getUserByName(String loginName) {
		String hql = "from User u where u.loginName=?";
		List<User> list = this.getHibernateTemplate().find(hql, loginName);
		return list;
	}
}
